{literal}
  <script type="text/javascript">
<!--
function confirmDelete(articleId) {
if (confirm("This will delete this category. Continue?"))
document.location = "admin.php?page=menus&action=delcat&id=" + articleId;
}
function confirmDelete2(articleId, ids) {
if (confirm("This will delete this item (And any child items). Continue?"))
document.location = "admin.php?page=menus&action=delitem&rid=" + articleId + "&id=" + ids;
}

function show(id)
{
	var item = null;
	if (document.getElementById)
	{
		item = document.getElementById(id);
	}
	else if (document.all)
	{
		item = document.all[id];
	}
	else if (document.layers)
	{
		item = document.layers[id];
	}

	if (item && item.style)
	{
        if (item.style.display == "none")
		{
			item.style.display = "";
		}
	}
	else if (item)
	{
		item.visibility = "show";
	}
}

function show_hide(id)
{
	var item = null;
    hideall();
	if (document.getElementById)
	{
		item = document.getElementById(id);
	}
	else if (document.all)
	{
		item = document.all[id];
	}
	else if (document.layers)
	{
		item = document.layers[id];
	}

	if (item && item.style)
	{
        if (item.style.display == "none")
		{
			item.style.display = "";
		}
	}
	else if (item)
	{
		item.visibility = "show";
	}
}

function hide(id)
{
	var item = null;
    var sub = null;
	if (document.getElementById)
	{
		item = document.getElementById(id);
	}
	else if (document.all)
	{
		item = document.all[id];
	}
	else if (document.layers)
	{
		item = document.layers[id];
	}

	if (item && item.style)
	{
       item.style.display = "none";
	}
	else if (item)
	{
		item.visibility = "hide";
	}
}

function hideall()
{
  	var item = null;
    var i = 0;
    
    var id = ['left', 'right', 'top'];
    for(i=0;i<3;i++)
    {
        if (document.getElementById)
        {
            item = document.getElementById(id[i]);
        }
        else if (document.all)
        {
            item = document.all[id[i]];
        }
        else if (document.layers)
        {
            item = document.layers[id[i]];
        }
        
        if (item && item.style)
        {
            item.style.display = "none";
        } 
    }
}

function itemss()
{
    var urlenabled = {/literal}{if $numpages > 0}true{else}false{/if}{literal};
    if (document.form2.items.selectedIndex==0 && urlenabled == true)
    {
        show_hide('urldiv');
    }
    else
    {
       hide('urldiv');
    }
}

function showitems(id)
{
	var item = null;
    var item2 = null;
    var writediv = null;
	if (document.getElementById)
	{
		item = document.getElementById('sub' + id);
		item2 = document.getElementById('subhide' + id);
       writediv = document.getElementById('mini'+id);
	}
	else if (document.all)
	{
		item = document.all['sub' + id];
		item2 = document.all['subhide' + id];
       writediv = document.all['mini' + id];
	}
	else if (document.layers)
	{
		item = document.layers['sub' + id];
		item2 = document.layers['subhide' + id];
       writediv = document.layers['mini' + id];
	}

	if (item && item.style)
	{
        if (item.style.display == "none")
		{
			item.style.display = "";
           item2.style.display = "none";
           writediv.innerHTML = '';
           writediv.innerHTML = '<a href="#" style="font-weight: bold;color: navy;margin: 3px 8px;text-decoration:none;" onclick="showitems(\''+id+'\');">[-]</a>';
		}
        else
        {
			item.style.display = "none";
           item2.style.display = "";
           writediv.innerHTML = '';
           writediv.innerHTML = '<a href="#" style="font-weight: bold;color: navy;margin: 3px 8px;text-decoration:none;" onclick="showitems(\''+id+'\');">[+]</a>';
        }
	}
	else if (item)
	{
        if (item.visibility == "hide")
		{
			item.visibility = "show";
           item2.visibility = "hide";
		}
        else
        {
			item.visibility = "hide";
           item2.visibility = "show";
        }
	}
}
//-->
  </script>
  {/literal}
{if $action == "view" || $action == ""}
<div align="center">
<input type="button" value="Left Menu" onclick="show_hide('left')" class="button" />&nbsp;<input type="button" value="Right Menu" onclick="show_hide('right')" class="button" />&nbsp;<input type="button" value="Top Menu" onclick="show_hide('top')" class="button" />
</div>
<div align="left"><input type="button" class="button" value="Add new menu" onclick="window.location='{$pagename}&amp;action=newcat'" /></div>
<div id="left"  {if $side=='left' || $side == ""}style="display: '';"{else}style="display: none;"{/if}>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
   <tr>
    <th class="bighead" colspan="4">Left Hand Menu</th>
 </tr>
  <tr>
    <th width="15%" scope="col" class="smallhead">Action</th>
    <th scope="col" class="smallhead">Name</th>
    <th width="5%" scope="col" class="smallhead">Items</th>
    <th width="10%" scope="col" class="smallhead">Position</th>
  </tr>
  {section name=cats loop=$numleft}
  <tr>
    <td class="text"><a href="{$pagename}&amp;action=catview&amp;id={$left[cats].id}"><img src="{$tempdir}admin/images/mod.gif" border="0" alt="Modify {$left[cats].name} items" title="Modify {$left[cats].name} items" /></a> - <a href="admin.php?page=menus&amp;action=editcat&amp;id={$left[cats].id}"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit {$left[cats].name}" title="Edit {$left[cats].name}" /></a> - <a href="javascript:confirmDelete({$left[cats].id})"><img src="{$tempdir}admin/images/delete.gif" border="0" alt="Delete {$left[cats].name}" title="Delete {$left[cats].name}" /></a></td>
    <td class="text">{$left[cats].name}</td>
    <td class="text">{$left[cats].numitems}</td>
    <td class="text">{if $smarty.section.cats.iteration != 1}<a href="{$pagename}&amp;action=moveup&amp;id={$left[cats].id}"><img src="{$tempdir}admin/images/up.gif" border="0" alt="Up" title="Move Up" /></a>&nbsp;{/if}{if $smarty.section.cats.iteration != $numleft}<a href="{$pagename}&amp;action=movedown&amp;id={$left[cats].id}"><img src="{$tempdir}admin/images/down.gif" border="0" alt="Up" title="Move Down" /></a>{/if}</td>
  </tr>
  {sectionelse}
  <tr>
  <td class="text" colspan="4">
   No categories in menu
  </td>
  </tr>
  {/section}
  </table>
</div>
<div id="right" {if $side=='right'}style="display: '';"{else}style="display: none;"{/if}>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
   <tr>
    <th class="bighead" colspan="4">Right Hand Menu</th>
 </tr>
  <tr>
    <th width="15%" scope="col" class="smallhead">Action</th>
    <th scope="col" class="smallhead">Name</th>
    <th width="5%" scope="col" class="smallhead">Items</th>
    <th width="10%" scope="col" class="smallhead">Position</th>
  </tr>
  {section name=cats loop=$numright}
  <tr>
    <td class="text"><a href="{$pagename}&amp;action=catview&amp;id={$right[cats].id}"><img src="{$tempdir}admin/images/mod.gif" border="0" alt="Modify {$right[cats].name} Items" title="Modify {$right[cats].name} Items" /></a> - <a href="admin.php?page=menus&amp;action=editcat&amp;id={$right[cats].id}"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit {$right[cats].name}" title="Edit {$right[cats].name}" /></a> - <a href="javascript:confirmDelete({$right[cats].id})"><img src="{$tempdir}admin/images/delete.gif" border="0" alt="Delete {$right[cats].name}" title="Delete {$right[cats].name}" /></a></td>
    <td class="text">{$right[cats].name}</td>
    <td class="text">{$right[cats].numitems}</td>
    <td class="text">{if $smarty.section.cats.iteration != 1}<a href="{$pagename}&amp;action=moveup&amp;id={$right[cats].id}"><img src="{$tempdir}admin/images/up.gif" border="0" alt="Up" title="Move Up" /></a>&nbsp;{/if}{if $smarty.section.cats.iteration != $numright}<a href="{$pagename}&amp;action=movedown&amp;id={$right[cats].id}"><img src="{$tempdir}admin/images/down.gif" border="0" alt="Up" title="Move Down" /></a>{/if}</td>
  </tr>  
  {sectionelse}
  <tr>
  <td class="text" colspan="4">
   No categories in menu
  </td>
  </tr>
  {/section}
  </table>
</div>
<div id="top" {if $side=='top'}style="display: '';"{else}style="display: none;"{/if}>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
   <tr>
    <th class="bighead" colspan="4">Top Menu</th>
 </tr>
  <tr>
    <th width="15%" class="smallhead">Action</th>
    <th scope="col" class="smallhead">Name</th>
    <th width="5%" scope="col" class="smallhead">Items</th>
    <th width="10%" scope="col" class="smallhead">Position</th>
  </tr>
  {section name=cats loop=$numtop}
  <tr>
    <td class="text"><a href="{$pagename}&amp;action=catview&amp;id={$top[cats].id}"><img src="{$tempdir}admin/images/mod.gif" border="0" alt="Modify {$top[cats].name} Items" title="Modify {$top[cats].name} Items" /></a> - <a href="admin.php?page=menus&amp;action=editcat&amp;id={$top[cats].id}"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit {$top[cats].name}" title="Edit {$top[cats].name}" /></a> - <a href="javascript:confirmDelete({$top[cats].id})"><img src="{$tempdir}admin/images/delete.gif" border="0" alt="Delete {$top[cats].name}" title="Delete {$top[cats].name}" /></a></td>
    <td class="text">{$top[cats].name}</td>
    <td class="text">{$top[cats].numitems}</td>
    <td class="text">{if $smarty.section.cats.iteration != 1}<a href="{$pagename}&amp;action=moveup&amp;id={$top[cats].id}"><img src="{$tempdir}admin/images/up.gif" border="0" alt="Up" title="Move Up" /></a>&nbsp;{/if}{if $smarty.section.cats.iteration != $numtop}<a href="{$pagename}&amp;action=movedown&amp;id={$top[cats].id}"><img src="{$tempdir}admin/images/down.gif" border="0" alt="Up" title="Move Down" /></a>{/if}</td>
  </tr>
      {sectionelse}
  <tr>
  <td class="text" colspan="4">
   No categories in menu
  </td>
  </tr>
  {/section}
</table>
</div>
<div align="left"><input type="button" class="button" value="Fix Positions" title="If you start getting strange error messages while moving menu items, click here" onclick="window.location='{$pagename}&amp;action=fixcat'" /></div>
<div align="left"><input type="button" class="button" value="Add new menu" onclick="window.location='{$pagename}&amp;action=newcat'" /></div>
  {elseif $action == "catview"}
  {if $numitems > 0}
  <h2>Links in {$menu.name}</h2>
<div align="left"><input type="button" class="button" value="Add Link" onclick="window.location='{$pagename}&amp;action=newitem&amp;id={$menu.id}&amp;type=link'" />&nbsp;<input type="button" class="button" value="Add Sidebox" onclick="window.location='{$pagename}&amp;action=newitem&amp;id={$menu.id}&amp;type=box'" /></div>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
  <tr>
    <th width="8%" scope="col" class="smallhead">Action</th>
    <th width="37%" scope="col" class="smallhead">Name</th>
    <th width="41%" scope="col" class="smallhead">Action of item</th>
    <th width="7%" scope="col" class="smallhead">Position</th>
  </tr>
{section name=items loop=$numitems}
  <tr>
    <td class="text"><a href="{$pagename}&amp;action=edititem&amp;cid={$menu.id}&amp;id={$item[items].id}"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit {$item[items].name}" title="Edit {$item[items].name}" /></a> - <a href="javascript:confirmDelete2({$item[items].id},{$menu.id})"><img src="{$tempdir}admin/images/delete.gif" border="0" alt="Delete {$item[items].name}" title="Delete {$item[items].name}" /></a></td>
    <td class="text"><div align="left">{$item[items].name}</div></td>
    <td class="text">{$item[items].action}</td>
    <td class="text">{if $smarty.section.items.iteration != 1}<a href="{$pagename}&amp;action=moveitemup&amp;id={$item[items].id}&amp;cid={$menu.id}"><img src="{$tempdir}admin/images/up.gif" border="0" alt="Up" title="Move Up" /></a>&nbsp;{/if}{if $smarty.section.items.iteration != $numitems}<a href="{$pagename}&amp;action=moveitemdown&amp;id={$item[items].id}&amp;cid={$menu.id}"><img src="{$tempdir}admin/images/down.gif" border="0" alt="Up" title="Move Down" /></a>{/if}</td>
  </tr>
  {if $item[items].subnumber > 0}
  <tr>
   <td class="text" valign="top"><div id="mini{$item[items].id}"><a href="#" style="font-weight: bold;color: navy;margin: 3px 8px;text-decoration:none;" onclick="showitems('{$item[items].id}');">[+]</a></div></td>
   <td colspan="3" class="text">
   <div id="subhide{$item[items].id}" style="display:'';">
    <div align="left">&nbsp;Item has <b>{$item[items].subnumber}</b> sub menu item(s).</div>
   </div>
   <div id="sub{$item[items].id}" style="display:none;">
    <strong><div align="left">Sub menu items:</div></strong>
    <table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
      <tr>
    <th width="8%" scope="col" class="smallhead">Action</th>
    <th width="37%" scope="col" class="smallhead">Name</th>
    <th width="41%" scope="col" class="smallhead">Action of item</th>
    <th width="7%" scope="col" class="smallhead">Position</th>
  </tr>
  {section name=subitem loop=$item[items].subnumber}
  <tr>
    <td class="text"><a href="{$pagename}&amp;action=edititem&amp;cid={$menu.id}&amp;id={$item[items].subitems[subitem].id}"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit {$item[items].subitems[subitem].name}" title="Edit {$item[items].subitems[subitem].name}" /></a>&nbsp;&nbsp;<a href="javascript:confirmDelete2({$item[items].subitems[subitem].id},{$menu.id})"><img src="{$tempdir}admin/images/delete.gif" border="0" alt="Delete {$item[items].subitems[subitem].name}" title="Delete {$item[items].subitems[subitem].name}" /></a></td>
    <td class="text"><div align="left">&nbsp;&nbsp;&nbsp;&nbsp;{$item[items].subitems[subitem].name} (Parent: {$item[items].name})</div></td>
    <td class="text">{$item[items].subitems[subitem].action}</td>
    <td class="text">{if $smarty.section.subitem.iteration != 1}<a href="{$pagename}&amp;action=moveitemup&amp;id={$item[items].subitems[subitem].id}&amp;cid={$menu.id}"><img src="{$tempdir}admin/images/up.gif" border="0" alt="Up" title="Move Up" /></a>&nbsp;{/if}{if $smarty.section.subitem.iteration != $item[items].subnumber}<a href="{$pagename}&amp;action=moveitemdown&amp;id={$item[items].subitems[subitem].id}&amp;cid={$menu.id}"><img src="{$tempdir}admin/images/down.gif" border="0" alt="Up" title="Move Down" /></a>{/if}</td>
  </tr>
   {/section}
   </table>
   </div>
   </td>
   </tr>
  {/if}
 {/section}
</table>
{else}
<div align="center">No menu items in {$menu.name}</div>
{/if}
<div align="left"><input type="button" class="button" value="Add Link" onclick="window.location='{$pagename}&amp;action=newitem&amp;id={$menu.id}&amp;type=link'" />&nbsp;<input type="button" class="button" value="Add Sidebox" onclick="window.location='{$pagename}&amp;action=newitem&amp;id={$menu.id}&amp;type=box'" /><br /><input type="button" class="button" value="Back" onclick="window.location='{$pagename}&side={$menu.side}'" /></div>
  {elseif $action == "newcat" || $action == "editcat"}
<form name="form1" method="post" action="">
  <p align="center">Name of Category: 
    <input name="name" type="text" id="name" value="{$menu.name}" class="inputbox" />
    <br />
    Location:<label>
    <input name="location" type="radio" value="left" {if $menu.side == 'left' ||  $menu.side == ''}checked{/if} />
Left</label>
    <label>
    <input type="radio" name="location" value="right" {if $menu.side == 'right'}checked{/if} />
Right</label>    
    <label>
    <input type="radio" name="location" value="top" {if $menu.side == 'top'}checked{/if} />
Top</label>    
    <br />
    <br />
    <label><input type="radio" name="show" value="1" {if $menu.showhead == 1 || $menu.showhead == ''}checked{/if} />Show Heading</label>
    <label><input name="show" type="radio" value="0" {if $menu.showhead == 0 && $menu.showhead != ''}checked{/if} />Hide Heading</label>
    <br />
    <br />
    <label><input type="radio" name="showperm" value="0" {if $menu.showwhen == 0}checked{/if} />Always Show</label>
    <label><input name="showperm" type="radio" value="1" {if $menu.showwhen == 1}checked{/if} />Show when logged in</label>
    <label><input name="showperm" type="radio" value="2" {if $menu.showwhen == 2}checked{/if} />Show when logged out</label>
    <br />
    <br />
    <label><input type="radio" name="expanded" value="1" {if $menu.expanded == 1}checked{/if} />Always show submenus</label>
    <label><input name="expanded" type="radio" value="0" {if $menu.expanded == 0}checked{/if} />Only show submenus when parent item is active</label>
    <br />
    <br />
    <input type="submit" name="Submit" value="Submit" class="button" />
     <input name="Cancel" type="button" id="Cancel" value="Cancel" onclick="history.go(-1);" class="button" />
</form>
{elseif $action == "newitem" || $action == "edititem"}
<h2>Add item for {$catname}</h2>
<form name="form2" method="post" action="">
  <div align="left">Name of menu item:
    <input name="name" type="text" id="name" value="{$item.name}" class="inputbox" size="50" />
    <br />
    {if $numpages > 0}
    Parent: 
    <select name="parent" id="parent" class="inputbox">
    <option value="0" {if $item.parent == '' || $item.parent == 'top'}selected="selected"{/if}>Top</option>
    {section name=parents loop=$numparents}
     <option value="{$parent[parents].id}" {if $item.parent == $parent[parents].id}selected="selected"{/if}>{$parent[parents].name}</option>
    {/section}
    </select><br />
    {/if}
    {if $numpages > 0 && $action != "edititem"}Link: {elseif $action != "edititem"}Sidebox: {else}Link/Sidebox: {/if}
    <select name="items" id="items" class="inputbox" onchange="itemss();">
      {if $numpages > 0}<option value="url" {if $item.item == '' || $item.item == 'url'}selected="selected"{/if}>URL</option>{/if}
      {section name=function loop=$numfunc}
	  	<option value="{$func[function].name}.{if $func[function].type == 1}box{elseif $func[function].type == 2}dyn{/if}" {if $item.item == $func[function].name}selected="selected"{/if}>{if $func[function].type == 1}Side Box: {elseif $func[function].type == 2}Dynamic Content: {/if}{$func[function].name}</option>
	  {/section}
      {section name=pages loop=$numpages}
        <option value="{$page[pages].name}.stat" {if $item.item == $page[pages].name}selected="selected"{/if}>Static Content: {if $page[pages].friendly == ""}{$page[pages].name}{else}{$page[pages].friendly}{/if}</option> 
     {/section}	  
      {section name=pages loop=$numsub}
        <option value="{$subsite[pages].name}.sub" {if $item.item == $subsite[pages].name}selected="selected"{/if}>Sub Site: {$subsite[pages].name}</option> 
     {/section}	  
    </select>
  </div>
     {if $numpages > 0}
     <div id="urldiv" style="display: {if $item.url == '' && $action == 'edititem'}none;{else}'';{/if}">
    URL: http://
    <input name="url" type="text" id="url" value="{$item.url}" class="inputbox" size="50" /></div>{/if}
    Target: <select name="target" id="target" class="inputbox">
    <option value="" {if $item.target == ''}selected="selected"{/if}>Same Window</option>
    <option value="_blank" {if $item.target == '_blank'}selected="selected"{/if}>New Window</option>
    </select>
    
  <div align="left">
    <input type="submit" name="Submit" value="Submit" class="button" />
    <input name="Cancel" type="button" id="Cancel" value="Cancel" onclick="history.go(-1);" class="button" />
   </div>
</form>
{/if}
<div align="center">
 <a href="http://www.cmscout.za.net/index.php?page=subsite&amp;site=Manual&amp;content=adminpanel-menu" target="_blank">Help</a>
</div>
